<?php

/**
 * Clientorder form.
 *
 * @package    briefing
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class ClientorderForm extends BaseClientorderForm
{
  public function configure()
  {
//    $subForm = new sfForm();
//    $editionOptions = new Editionoptions();
//    $editionOptions->get
    
    
    
    ////fields not editable by final user
    unset(
      $this['created_at'], $this['updated_at'],
      $this['expires_at'], $this['is_activated']
//      $this['editionoptionsid']
    );
    
    //change labels
    $this->widgetSchema->setLabels(array(
        'ordername' => 'Order name',
        'textcategoryid' => 'Category',
        'targetgroupid'=>'Target group',
        'formalstyleid'=>'Style',
        'personstyleid'=>'Person form',
        'emotionstyleid'=>'Emotion style',
        'formulateid'=>'Formulate',
        'urlimagestructure'=>'Order logo',
        'is_standard'=>'Standard',
        
        
        
        //intentar poner en widget form choice
        'is_website' => 'Website',
        'is_print' => 'Print',
        'is_newsletter' => 'Newsletter',
        'is_poster' => 'Poster',
        'is_blog' => 'Blog',
        'is_women' => 'Women',
        'is_men' => 'Men',
        'is_new_customer' => 'New customer',
        'is_existing_custormer' => 'Existing customer',
    ));
    
    $this->widgetSchema['ordername']->setAttribute('size',80);
    $this->widgetSchema['textcategoryid']->setAttribute('style',"width: 300px;");
    $this->widgetSchema['targetgroupid']->setAttribute('style',"width: 300px;");
    $this->widgetSchema['formalstyleid']->setAttribute('style',"width: 300px;");
    $this->widgetSchema['personstyleid']->setAttribute('style',"width: 300px;");
    $this->widgetSchema['emotionstyleid']->setAttribute('style',"width: 300px;");
    $this->widgetSchema['formulateid']->setAttribute('style',"width: 300px;");

    
// create a new sfWidgetFormSchema which stores the edition options widgets
      $editionWidgetSchema  = new sfWidgetFormSchema;
//      $editionWidgetSchema->addOption('superlative', 
//            $this->validatorSchema['editionoptionsid']->getOption('is_superlative'));
//    (array(
//        'choices' => Doctrine_Core::getTable('EditionOptions')->getEditionOptionsX(),
//        'multiple' => true,
//        'expanded' => true,
//        'label' => 'Edition options',
//    ));
//    
//    $this->validatorSchema['editionoptionsid'] = new sfValidatorSchema(array(
//        'choices' => array_keys(Doctrine_Core::getTable('EditionOptions')->getEditionOptionsX()),
//        'multiple' => true,
//    ));
      $editionWidgetSchema['edoptions'] = new sfWidgetFormChoice(array(
        'choices' => Doctrine_Core::getTable('EditionOptions')->getEditionOptionsX(),
        'multiple' => true,
        'expanded' => true,
        'label' => 'Edition options',
      ));
      $editionWidgetSchema['ownchoice'] = new sfWidgetFormFilterInput(array(
        'label' => 'Own choice',
        'with_empty' => false,
      ));
    
      
      // create a new sfValidatorFormSchema which hold the user's validator
      $editionValidatorSchema = new sfValidatorSchema;
      $editionValidatorSchema['edoptions'] = new sfValidatorChoice(array(
        'choices' => array_keys(Doctrine_Core::getTable('EditionOptions')->getEditionOptionsX()),
        'multiple' => true,
      ));
      $editionValidatorSchema['ownchoice'] = new sfValidatorPass();
    
      $this->widgetSchema['editionoptionsid'] = $editionWidgetSchema;
      $this->validatorSchema['editionoptionsid'] = $editionValidatorSchema;
    

    
    // Existing forms
//    $x = 'is_superlative';
//    $this->embedRelation('editionoptions[%s]',$x);//'editionOptionsId');
    
    //Other Media
//    $this->widgetSchema['otherchoice'] = new sfWidgetFormFilterInput(array(
//        'label' => 'Other edition options',
//        'with_empty' => false,
//    ));
//    
//    $this->validatorSchema['otherchoice'] = new sfValidatorPass();
    
    //edition options
//    $this->widgetSchema['editionoptionsid'] = new sfWidgetFormChoice(array(
//        'choices' => Doctrine_Core::getTable('EditionOptions')->getEditionOptionsX(),
//        'multiple' => true,
//        'expanded' => true,
//        'label' => 'Edition options',
//    ));
//    $this->validatorSchema['editionoptionsid'] = new sfValidatorChoice(array(
//        'choices' => array_keys(Doctrine_Core::getTable('EditionOptions')->getEditionOptionsX()),
//        'multiple' => true,
//    ));
    
    
    //edition options
//    $this->widgetSchema['editionoptionsid'] = new sfWidgetFormSchema(array(
//        'label' => 'Edition options',
//        'with_empty' => false,
//    ));
//    
//    $this->validatorSchema['editionoptionsid'] = new sfValidatorPass();
    
    
    
    //Other Media
    $this->widgetSchema['othertextmediumid'] = new sfWidgetFormInputText(array(//FilterInput(array(
        'label' => 'Other media',
//        'with_empty' => false,
    ));
    $this->widgetSchema['othertextmediumid']->setAttribute('size', 45);
    $this->validatorSchema['othertextmediumid'] = new sfValidatorString();//new sfValidatorPass();

    //++++++++++++++++++++++++++++++++++++++++++++
    //Free text - As text area
    $this->widgetSchema['freetextid'] = new sfWidgetFormTextarea(array(
        'label' => 'Free text',
        'default' => 'Write a free text if you consider it necessary',
    ));
    $this->widgetSchema['freetextid']->setAttribute('cols', 70);
    
    
    
    $this->validatorSchema['freetextid'] = new sfValidatorString();
      //as input
//    $this->widgetSchema['freetextid'] = new sfWidgetFormFilterInput(array(
//        'label' => 'Free text',
//        'with_empty' => false,
//    ));
//    
//    $this->validatorSchema['freetextid'] = new sfValidatorPass();
    
    //++++++++++++++++++++++++++++++++++++++++++++
    
    
    //URL image
    $this->widgetSchema['urlimagestructure'] = new sfWidgetFormInputFile(array(
        'label' => 'Company logo order',
    ));
    
    $this->validatorSchema['urlimagestructure'] = new sfValidatorFile(array(
      'required'   => false,
      'path'       => sfConfig::get('sf_upload_dir').'/orders',
      'mime_types' => 'web_images',
    ));
  
    //HELP
    //$this->widgetSchema->setHelp('is_women', 'Whether the order ...');
    $this->widgetSchema->setHelp('is_standard', 'Is it an standard order?');
    
  }
}
